package com.ymatou.iapi.csim.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.csim.parameter.DiscourseDto;
import com.ymatou.iapi.csim.parameter.FetchIndividualDiscourseFetchByIdBean;
import com.ymatou.iapi.csim.parameter.SaveOrUpdateIndividualDiscourseBean;
import com.ymatou.iapi.csim.service.FetchIndividualDiscourseFetchByIdCall;
import com.ymatou.iapi.csim.service.SaveOrUpdateIndividualDiscourseCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.CsimCallService;
import com.ymttest.database.model.ymt_discourse;
import com.ymttest.database.model.ymt_individualdiscourse;
import com.ymttest.database.sqlwapper.CSIM.ymt_individualdiscourseWapper;
import com.ymttest.utils.EnvSetup;
import com.ymttest.utils.TestDataManager;
/**
*通过Id获取个人话术
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_FetchIndividualDiscourseFetchById{
	private static FetchIndividualDiscourseFetchByIdBean bean;
	private static FetchIndividualDiscourseFetchByIdCall call;
	
	private static SaveOrUpdateIndividualDiscourseBean saveorupdateindividualdiscourseBean=new SaveOrUpdateIndividualDiscourseBean();
	private static SaveOrUpdateIndividualDiscourseCall saveorupdateindividualdiscourseCall=new SaveOrUpdateIndividualDiscourseCall();
	private ymt_individualdiscourseWapper individualdiscourseWapper=new ymt_individualdiscourseWapper();
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("通过Id获取个人话术");
	}

	@Before
	public void caseUp() {
		bean=new FetchIndividualDiscourseFetchByIdBean();
		call=new FetchIndividualDiscourseFetchByIdCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(call.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_FetchIndividualDiscourseFetchById_1() {
		Logger.start(true,"通过Id获取个人话术");
		try {
			saveorupdateindividualdiscourseBean.setId(TestDataManager.getRandomUUID().toString());
			saveorupdateindividualdiscourseBean.setCategoryId(TestDataManager.getRandomUUID().toString());
			saveorupdateindividualdiscourseBean.setTitle("自动化测试_"+TestDataManager.getRandomNum(5));
			saveorupdateindividualdiscourseBean.setSort(1);
			saveorupdateindividualdiscourseCall.setData(saveorupdateindividualdiscourseBean);
			saveorupdateindividualdiscourseCall.callService();
			
			bean.setCategoryId(saveorupdateindividualdiscourseBean.getCategoryId());
			bean.setId(saveorupdateindividualdiscourseBean.getId());
			call.setData(bean);
			call.callService();	

			//验证
			DiscourseDto disCall=call.getData().getResult();
			ymt_individualdiscourse discourse=individualdiscourseWapper.selectByPrimaryKey(saveorupdateindividualdiscourseBean.getId());
			
			Logger.verifyEquals("200", call.getStatus(), "验证status");
			Logger.verifyEquals("", call.getMsg(), "验证Msg");
			
			Logger.verifyEquals(disCall.getId(), discourse.getId(), "验证Id");
			Logger.verifyEquals(disCall.getCategoryId(), discourse.getCategoryId(), "验证CategoryId");
			Logger.verifyEquals(disCall.getTitle(), discourse.getTitle(), "验证Title");
			Logger.verifyEquals(disCall.getCsId(),0, "验证CsId");
			Logger.verifyEquals(disCall.getSort(), discourse.getSort(), "验证Sort");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}